home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / Interim Executive Decision / patch / asdf.c next >
Encoding:
C/C++ Source or Header  |  1998-06-21  |  1.9 KB  |  106 lines  |  [TEXT/CWIE]

  1. #include <Gestalt.h>
  2. #include <Patches.h>
  3. #include <Resources.h>
  4. #include <TextUtils.h>
  5. #include <Types.h>
  6.  
  7. //============================================================================
  8.  
  9. long SetA4(long:__D0):__D0 = 0xC18C;
  10.  
  11. //============================================================================
  12.  
  13. pascal
  14. OSErr
  15. (*gOldGestalt)
  16. (
  17.     OSType                 selector:__D0,
  18.     long *                response:__A1
  19. ):__D0;
  20.  
  21. //============================================================================
  22.  
  23. asm
  24. OSErr
  25. GestaltPatch
  26. (
  27.     OSType                 selector:__D0,
  28.     long *                response:__A1
  29. ):__D0;
  30.  
  31. //============================================================================
  32.  
  33. asm
  34. OSErr
  35. GestaltPatch
  36. (
  37.     OSType                 selector:__D0,
  38.     long *                response:__A1
  39. ):__D0
  40. {
  41.     link      a6,#0
  42.     movem.l   d3-d5/a2,-(a7)
  43.     move.l    d0,d5
  44.     movea.l   a1,a2
  45.     moveq     #0,d3
  46.     jsr       0(a4)
  47.     ext.l     d0
  48.     move.l    d0,d4
  49.     cmpi.l    #1397770785,d5
  50.     bne.s     *+10           ; 0x00000026
  51.     move.l    #-559038737,(a2)
  52.     bra.s     *+14           ; 0x00000032
  53.     movea.l   0(a4),a0
  54.     move.l    d5,d0
  55.     movea.l   a2,a1
  56.     jsr       (a0)
  57.     move.w    d0,d3
  58.     move.l    d4,d0
  59.     exg       d0,a4
  60.     moveq     #0,d0
  61.     movem.l   (a7)+,d3-d5/a2
  62.     unlk      a6
  63.     rts
  64. /*
  65.     OSErr                err = noErr;
  66.     long                oldA4;
  67.     Str255                debugInfo;
  68.  
  69.     oldA4 = SetCurrentA4();
  70.  
  71.     if (selector == 'SPJ!')
  72.     {
  73.         *response = 0xdeadbeef;
  74.     }
  75.     else
  76.     {
  77.         err = gOldGestalt(selector, response);
  78.     }
  79.  
  80.     SetA4(oldA4);
  81.  
  82.     return noErr;
  83. */
  84. }
  85.  
  86. //============================================================================
  87.  
  88. void main (void)
  89. {
  90.     long            oldA4 = SetCurrentA4();
  91.     Str255            debugInfo;
  92.  
  93.     gOldGestalt =
  94.         (pascal OSErr (*)(OSType selector:__D0, long* response:__A1):__D0)
  95.         NGetTrapAddress(0xA1AD, kOSTrapType);
  96.  
  97.     NSetTrapAddress((UniversalProcPtr)GestaltPatch, 0xA1AD, kOSTrapType);
  98.  
  99.     DetachResource(GetResource('INIT', 0));
  100.     
  101.     SetA4(oldA4);
  102. }
  103.  
  104. //============================================================================
  105.  
  106.